<div data-hook="admin_store_form_fields">

<div class="card mb-4">
  <div class="card-header">
    <h1 class="card-title mb-0 h5">
      <%= Spree.t(:basic_information) %>
    </h1>
  </div>
  <div class="card-body">
    <%= f.field_container :logo, class: ['form-group'] do %>
      <% if @store.logo.attached? && @store.logo.variable? %>
        <%= image_tag main_app.url_for(@store.logo.variant(resize: '244x104>')) %>
      <% elsif @store.logo.attached? && @store.logo.image? %>
        <%= image_tag main_app.url_for(@store.logo) %>
      <% end %>
      <%= f.field_container :logo, class: ['form-group'] do %>
        <%= f.label :logo, Spree.t(:logo) %><br>
        <%= f.file_field :logo %>
        <%= f.error_message_on :logo %>
      <% end %>
    <% end %>
    <%= f.field_container :mailer_logo, class: ['form-group'] do %>
      <% if @store.mailer_logo.attached? && @store.mailer_logo.variable? %>
        <%= image_tag main_app.url_for(@store.mailer_logo.variant(resize: '244x104>')) %>
      <% end %>
      <%= f.field_container :mailer_logo, class: ['form-group'] do %>
        <%= f.label :mailer_logo, Spree.t(:mailer_logo) %><br>
        <%= f.file_field :mailer_logo, accept: 'image/png, image/jpeg' %>
        <%= f.error_message_on :mailer_logo %>
      <% end %>
    <% end %>
    <%= f.field_container :name, class: ['form-group'] do %>
      <%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>
      <%= f.text_field :name, class: 'form-control', required: true %>
      <%= f.error_message_on :name %>
    <% end %>
    <%= f.field_container :code, class: ['form-group'] do %>
      <%= f.label :code, raw(Spree.t(:code) + required_span_tag) %>
      <%= f.text_field :code, class: 'form-control', required: true %>
      <small class="form-text text-muted">
        <%= Spree.t('store_form.code_help') %>
      </small>
      <%= f.error_message_on :code %>
    <% end %>
    <%= f.field_container :url, class: ['form-group'] do %>
      <%= f.label :url, raw(Spree.t(:url) + required_span_tag) %>
      <div class="input-group mb-3">
        <div class="input-group-prepend">
          <span class="input-group-text" id="basic-addon3">https://</span>
        </div>
        <%= f.text_field :url, class: 'form-control', required: true %>
      </div>
      <%= f.error_message_on :url %>
    <% end %>
  </div>
</div>

<div class="card mb-4">
  <div class="card-header">
    <h1 class="card-title mb-0 h5">
      <%= Spree.t(:seo) %>
    </h1>
  </div>
  <div class="card-body">
    <%= f.field_container :seo_title, class: ['form-group'] do %>
      <%= f.label :seo_title, Spree.t(:seo_title) %>
      <%= f.text_field :seo_title, class: 'form-control' %>
      <%= f.error_message_on :seo_title %>
    <% end %>
    <%= f.field_container :meta_description, class: ['form-group'] do %>
      <%= f.label :meta_description, Spree.t(:meta_description) %>
      <%= f.text_area :meta_description, class: 'form-control' %>
      <%= f.error_message_on :meta_description %>
    <% end %>
    <%= f.field_container :meta_keywords, class: ['form-group'] do %>
      <%= f.label :meta_keywords, Spree.t(:meta_keywords) %>
      <%= f.text_field :meta_keywords, class: 'form-control' %>
      <%= f.error_message_on :meta_keywords %>
    <% end %>
    <%= f.field_container :seo_robots, class:['form-group']  do %>
      <%= f.label :seo_robots, Spree.t(:seo_robots) %>
      <%= f.text_field :seo_robots, class: 'form-control' %>
      <%= f.error_message_on :seo_robots %>
      <small class="form-text text-muted">
        <%= raw(Spree.t('store_form.seo_robots')) %>
      </small>
    <% end %>
  </div>
</div>

<div class="card mb-4">
  <div class="card-header">
    <h1 class="card-title mb-0 h5">
      <%= Spree.t(:email).pluralize %>
    </h1>
  </div>
  <div class="card-body">
    <%= f.field_container :mail_from_address, class: ['form-group'] do %>
      <%= f.label :mail_from_address, raw(Spree.t(:mail_from_address)  + required_span_tag) %>
      <%= f.text_field :mail_from_address, class: 'form-control', required: true %>
      <%= f.error_message_on :mail_from_address %>
      <small class="form-text text-muted">
        <%= Spree.t('store_form.mail_from_address_help') %>
      </small>
    <% end %>

    <%= f.field_container :customer_support_email, class: ['form-group'] do %>
      <%= f.label :customer_support_email, Spree.t(:customer_support_email) %>
      <%= f.text_field :customer_support_email, class: 'form-control' %>
      <%= f.error_message_on :customer_support_email %>
      <small class="form-text text-muted">
        <%= Spree.t('store_form.customer_support_email_help') %>
      </small>
    <% end %>

    <%= f.field_container :new_order_notifications_email, class: ['form-group'] do %>
      <%= f.label :new_order_notifications_email, Spree.t(:new_order_notifications_email) %>
      <%= f.text_field :new_order_notifications_email, class: 'form-control' %>
      <%= f.error_message_on :new_order_notifications_email %>
      <small class="form-text text-muted">
        <%= Spree.t('store_form.new_order_notifications_email_help') %>
      </small>
    <% end %>
  </div>
</div>

<div class="card mb-4">
  <div class="card-header">
    <h1 class="card-title mb-0 h5">
      <%= Spree.t(:internationalization) %>
    </h1>
  </div>
  <div class="card-body">
    <%= f.field_container :default_currency, class: ['form-group'] do %>
      <%= f.label :default_currency %>
      <%= f.select :default_currency, currency_options(@store.default_currency), {}, { class: 'select2' } %>
      <%= f.error_message_on :default_currency %>
    <% end %>
    <%= f.field_container :supported_currencies, class: ['form-group'] do %>
      <%= f.label :supported_currencies, Spree.t(:supported_currencies) %>
      <%= f.select :supported_currencies, currency_options(@store.supported_currencies&.split(',')), { prompt: false }, { multiple: true, class: 'select2' } %>
      <%= f.error_message_on :supported_currencies %>
    <% end %>
    <%= f.field_container :checkout_zone_id, class: ['form-group'] do %>
      <%= f.label :checkout_zone_id, Spree.t(:zone) %>
      <%= f.select :checkout_zone_id, options_for_select(@zones, selected_checkout_zone(@store)&.id), { include_blank: Spree.t(:no_limits_zone) }, { class: 'select2' } %>
      <small class="form-text text-muted">
        <%= raw(Spree.t('store_form.checkout_zone_help')) %>
      </small>
      <%= f.error_message_on :checkout_zone_id %>
    <% end %>
    <%= f.field_container :default_locale, class: ['form-group'] do %>
      <%= f.label :default_locale %>
      <%= f.select :default_locale, options_from_collection_for_select(all_locales_options, :last, :first, @store.default_locale || I18n.locale), {}, { class: 'select2' } %>
      <%= f.error_message_on :default_locale %>
      <% unless defined?(SpreeI18n) %>
        <small class="form-text text-muted">
          <%= raw(Spree.t('store_form.locales_help')) %>
        </small>
      <% end %>
    <% end %>
    <%= f.field_container :supported_locales, class: ['form-group'] do %>
      <%= f.label :supported_locales, Spree.t(:supported_locales) %>
      <%= f.select :supported_locales, options_from_collection_for_select(all_locales_options, :last, :first, @store.supported_locales&.split(',')), {}, { multiple: true, class: 'select2' } %>
      <%= f.error_message_on :supported_locales %>
    <% end %>
    <%= f.field_container :default_country_id, class: ['form-group'] do %>
      <%= f.label :default_country_id, Spree.t('i18n.default_country') %>
      <%= f.select :default_country_id, options_from_collection_for_select(@countries, :id, :name, @store.default_country_id || Spree::Config[:default_country_id]), {}, { class: 'select2' } %>
      <%= f.error_message_on :default_country_id %>
      <small class="form-text text-muted">
        <%= Spree.t('store_form.default_country_help') %>
      </small>
    <% end %>
  </div>
</div>

<div class="card mb-4">
  <div class="card-header">
    <h1 class="card-title mb-0 h5">
      <%= Spree.t(:social) %>
    </h1>
  </div>
  <div class="card-body">
    <div class="alert alert-warning col-12">
      <%= Spree.t('store_form.social_help') %>
    </div>

    <%= f.field_container :facebook, class: ['form-group'] do %>
      <%= f.label :facebook, Spree.t(:facebook) %>
      <div class="input-group mb-3">
        <div class="input-group-prepend">
          <span class="input-group-text" id="basic-addon3">https://facebook.com</span>
        </div>
        <%= f.text_field :facebook, class: 'form-control' %>
      </div>
      <%= f.error_message_on :facebook %>
    <% end %>
    <%= f.field_container :twitter, class: ['form-group'] do %>
      <%= f.label :twitter, Spree.t(:twitter) %>
      <div class="input-group mb-3">
        <div class="input-group-prepend">
          <span class="input-group-text" id="basic-addon3">https://twitter.com</span>
        </div>
        <%= f.text_field :twitter, class: 'form-control' %>
      </div>
      <%= f.error_message_on :twitter %>
    <% end %>
    <%= f.field_container :instagram, class: ['form-group'] do %>
      <%= f.label :instagram, Spree.t(:instagram) %>
      <div class="input-group mb-3">
        <div class="input-group-prepend">
          <span class="input-group-text" id="basic-addon3">https://instagram.com</span>
        </div>
        <%= f.text_field :instagram, class: 'form-control' %>
      </div>
      <%= f.error_message_on :instagram %>
    <% end %>
  </div>
</div>

<div class="card mb-4">
  <div class="card-header">
    <h1 class="card-title mb-0 h5">
      <%= Spree.t(:footer) %>
    </h1>
  </div>
  <div class="card-body">
    <div class="alert alert-warning col-12">
      <%= Spree.t('store_form.footer_help') %>
    </div>

    <%= f.field_container :description, class: ['form-group'] do %>
      <%= f.label :description, Spree.t(:description) %>
      <%= f.text_area :description, class: 'form-control' %>
      <%= f.error_message_on :description %>
    <% end %>
    <%= f.field_container :address, class: ['form-group'] do %>
      <%= f.label :address, Spree.t(:address) %>
      <%= f.text_area :address, class: 'form-control' %>
      <%= f.error_message_on :address %>
    <% end %>
    <%= f.field_container :contact_phone, class: ['form-group'] do %>
      <%= f.label :contact_phone, Spree.t(:contact_phone) %>
      <%= f.text_field :contact_phone, class: 'form-control' %>
      <%= f.error_message_on :contact_phone %>
    <% end %>
  </div>
</div>
